<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<script src="./bitcore-lib-cash.js"></script>
	<script src="./buffer.js"></script>
	<script src="./bitcore-lib-freecash.js"></script>
	<script src="./bitcore-mnemonic.js"></script>
	<script src="./bitcore-lib.js"></script>
	<script src="./bchaddrjs-0.4.2.js"></script>
	<script src="./bitcore-message.js"></script>
	<script src="./all-api.js"></script>
	<script src="./bip-schnorr.js"></script>
	<script src="./bignumber.js"></script>
	<script src="./bitcore-ecies.js"></script>
	
</head>

<body>
    <script type="text/javascript">
	
	var privateKey=BitcoreLib.PrivateKey.fromWIF("KwLrLzvsh4GYAk6Zzjs5ThciutYCGuHYtXgqhnQKXYSvb8b5YhTW");

	
	
	var data=encryptData("hello world",privateKey.toPublicKey().toString())
	var xxx=decryptData(data,"KwLrLzvsh4GYAk6Zzjs5ThciutYCGuHYtXgqhnQKXYSvb8b5YhTW");
	console.log(xxx);
	/**
	 var privateKey=BitcoreLib.PrivateKey.fromWIF("KwLrLzvsh4GYAk6Zzjs5ThciutYCGuHYtXgqhnQKXYSvb8b5YhTW");
	 var bigint=BipSchnorr.base.BI.fromHex(privateKey.toString());
	var value = new buffer.Buffer("hello schnorr");
		var hash = BitcoreLib.crypto.Hash.sha256(value);
     var sigstr=BipSchnorr.sign(bigint,hash);
	 console.log(sigstr);
	
	var r=getPublickKeyFromWIF('fch','KzpJU6T6dhBsgifeNE4VMZBbhVTmi2QiK3UtN8CtmFT7rnBQ4XAo');
	
	console.log(r);
	**/
	//1NsnkNPzi5iRirf8ycD2C76ctjWnYbpBDT
	//1NsnkNPzi5iRirf8ycD2C76ctjWnYbpBDT
    //var addrBch = addressConvert('bch',"1F3c4AdEUxwWEo64k15LyftN8n7eZkckjU");
	// 	//0100000002ba7b802d10429e5b952ad384965df9ca5f923054a0219cfb2d7df88b8c615901000000006b483045022100d24d054dde15be1d09c1700fd783e8f0af22e8408634cb6a25c913f4d93729cf0220278b34ad40bc7422185d8f09a329b86e221452b3d6c7b910a32de8287088933c412102316a38f51bcefdb37138d574a3770d051487874d6b41475f061e9bdd59232082ffffffff4c5ee81e2e3e28e1387c3b8e9820ced98ee8411dc5b0caf2553ea99157329701020000006a47304402206a1a840a030735d92cc533f09184b56e0bbe2f3286459b3fff4ee3823d40bf2b02206c01cdf0770d293fad029d9770ef4d151e05904721fa21642f9f545f8d466e8c4121032746ae4811a6e302222b64e11b3f22b27f35bfee49b8fadb71c62e309bacf2ccffffffff0340420f00000000001976a9147e517ce48da51f81edbe97df591f8567e9c1ee9388ac40548900000000001976a914c714ea12b551d2d820712db4d6f2a4b61a2c2bee88acd8c22d00000000001976a91437b027f06ce41b757e66a8e9c5e98ae93ab86cae88ac00000000
    //console.log(addrBch);
	//var sig=createTranscationSig();
	
	var privatekeys=['KzpJU6T6dhBsgifeNE4VMZBbhVTmi2QiK3UtN8CtmFT7rnBQ4XAo','L5LZd6XB9ZrqrXHDzFBXpHd1mYsV7spXpVshVsPswtJKhTFGQdne'];
	var txids=['0159618c8bf87d2dfb9c21a05430925fcaf95d9684d32a955b9e42102d807bba','0197325791a93e55f2cab0c51d41e88ed9ce20988e3b7c38e1283e2e1ee85e4c'];
	var inputamounts=[0.1,0.03];
	var indexs=[0,2];
	var outputaddres=['FThuDAq5ZPw6M2YAqHsBAVd9vPXoUySE7i','FThuDAq5ZPw6M2YAqHsBAVd9vPXoUySE7i'];
	var outputamounts=[0.01,0.09];
	var returnaddr='165TC5vtWp2yH2P6PC6dRGTZdVoYSPRFsB';
	var fee=0.00001;
	sig=createBchTranscationSig(privatekeys,txids,inputamounts,indexs,outputaddres,outputamounts,returnaddr,fee);
	console.log(sig);
    
	//var s="0200000002ba7b802d10429e5b952ad384965df9ca5f923054a0219cfb2d7df88b8c615901000000006441419010cce61638e65c1a662bb7c93aa67420e37c44d51fdc01e207d99929d93a18faa52cf989dd3de9c457b719e2e5e81b6cc6a86b254edc372501165fe003af412102316a38f51bcefdb37138d574a3770d051487874d6b41475f061e9bdd59232082ffffffff4c5ee81e2e3e28e1387c3b8e9820ced98ee8411dc5b0caf2553ea99157329701020000006441e6e412e9a57eb2eaca342dff5dd52d7c5045a658240d4ee943501404c126f71bf9830edfa6fbda8e0827243a6d8522f9acf06bab4a416e579beb1d1eaf8cd0104121032746ae4811a6e302222b64e11b3f22b27f35bfee49b8fadb71c62e309bacf2ccffffffff0340420f00000000001976a914eff5a0ba0abbf3726b2fb8dcc7ab7364c9ec0b4988ac40548900000000001976a914eff5a0ba0abbf3726b2fb8dcc7ab7364c9ec0b4988acd8c22d00000000001976a91437b027f06ce41b757e66a8e9c5e98ae93ab86cae88ac00000000";
	//var ts=new BitcoreLib.Transaction(s);
	//console.log(ts.toJSON());
	 /**                                             b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfef
	var p=BitcoreLibFreeCash.PrivateKey.fromString('B7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF');
	console.log(p.toString());
	var privateKey1 = BipSchnorr.base.BI.fromHex('B7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF');
    var privateKey2 = BipSchnorr.base.BI.fromHex('C90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C7');
    var message = BipSchnorr.base.BF.from('243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89', 'hex');
    var aggregatedSignature = BipSchnorr.muSig.nonInteractive([privateKey1, privateKey2], message);
	console.log(aggregatedSignature);
	// const schnorr = require('schnorr');
    // const secp256k1 = require('./Secp256k1.js');
     //const hash256 = require('bcrypto/lib/hash256');
	// const key = secp256k1.privateKeyGenerate();
     //const pub = secp256k1.publicKeyCreate(key, true);
     //const msg = hash256.digest(Buffer.from('foo', 'ascii'));
     //const sig = schnorr.sign(msg, key);
	 //schnorr.verify(msg, sig, pub)
**/
//aGVsbG8sd29ybGQ=
/**
	var feip3=encodeFEIP003("cm",["足球","读书"],2);
	var feip4=encodeFEIP004(4);
	console.log(feip4);
**/
	/**
    var privatekeys=['KwLrLzvsh4GYAk6Zzjs5ThciutYCGuHYtXgqhnQKXYSvb8b5YhTW','KwLrLzvsh4GYAk6Zzjs5ThciutYCGuHYtXgqhnQKXYSvb8b5YhTW'];
	var txids=['4a6bef758ae46c4610e5970e75d87effb8630eb3c8d2401008b78fc73f86d41e','11b0355015a1ca9d26bd82a26d7600bfbbb40afca2fea6e28d49b91da2a67bed'];
	var inputamounts=['25','25'];
	var indexs=[0,0];
	var outputaddres=['F8TWjdrQ4vFjB772iWeyw4gQnjaKzy7QVb','F8TWjdrQ4vFjB772iWeyw4gQnjaKzy7QVb','FHDq2gN7RihW1opgR8jTkYYcb5kznTMaXg'];
	var outputamounts=['0.003','0.003','0.11'];
	var returnaddr='FHDq2gN7RihW1opgR8jTkYYcb5kznTMaXg';
	var fee='0.000001';
	sig=createFchTranscationSig(privatekeys,txids,inputamounts,indexs,[],[],"",fee,"5L2g5aW95Lit5Zu9",2);
	console.log(sig);
	**/
	/**
	  var privatekeys=['KwLrLzvsh4GYAk6Zzjs5ThciutYCGuHYtXgqhnQKXYSvb8b5YhTW'];
	var txids=['4a6bef758ae46c4610e5970e75d87effb8630eb3c8d2401008b78fc73f86d41e'];
	var inputamounts=['25'];
	var indexs=[0];
	var outputaddres=['F8TWjdrQ4vFjB772iWeyw4gQnjaKzy7QVb'];
	var outputamounts=['0.003'];
	var returnaddr='FHDq2gN7RihW1opgR8jTkYYcb5kznTMaXg';
	var fee='0.000001';
	sig=createFchTranscationSig(privatekeys,txids,inputamounts,indexs,outputaddres,outputamounts,returnaddr,fee,"",1);
	console.log(sig);
	**/
	
    /**
	var msg=signMessage('btc','cPBn5A4ikZvBTQ8D7NnvHZYCAxzDZ5Z2TSGW2LkyPiLxqYaJPBW4','1234');
	msg='H1Kzi/EqireCg/kGnhhPgQx5IT5jeCgmcTyvv1v6woaVSLMelCiS+LWM+IHWwrGgYpHMh3rsegd7tXONaCFGQK4=';
	console.log(msg);
	var signmsg=messageVerify('bch',"bitcoincash:qzdqlkhq4xklkqcw8lde9dwcs7kzmazasgaex56gqf",'a',msg);
	console.log(signmsg);
	**/
	//var code=mnemonicWord('bch','的 去 次 收 深 官 负 袁 训 伤 鼓 楼',"m/0'/145'/1'/1/2");
	//ar code=mnemonicWord('bch','faculty matrix spoon adult enemy soon broccoli solution scissors speed negative cross',"m/0'/145'/1'/1/2");
	//console.log(code);
	 
	/**
	var p=BitcoreLibFreeCash.PrivateKey.fromString('5HxWvvfubhXpYYpS3tJkw6fq9jE9j18THftkZjHHfmFiWtmAbrj');
	console.log(p.toString());
	console.log(p.toWIF());**/
	//var p=importAdressFromWIF('fch','Kz8imAGRhYEMcxjiVBudgRctgJBmhRo5zwnDqcE94keyu6DLJZNN');
	//console.log(p);
	/**
	var at=addressType('F8XQPPbRyTwuQjMLvkLJgPxUuQhSt3MPRQ');
	console.log(at);
	var inputprivatekeys =new Array("KzhGyRo7jFNrCS4BnZRUrAiP9pLrsLWCYsCD13T3XHSY7R4xfsUs");
	var txids =["b117cf3b8e601d71e0bfc9c57b3d7bc05454b309ffb5fde042bd1e5260e5c35d"];
	var inputamounts =[1.0];
	var indexs=[1];
	var outputaddresses =new Array("bitcoincash:qpw2sn0yufl43u9vnk55mkhefuqzq3g3zvqfacspgr");
	var outputamounts =[1.0];
	var returnaddr ="";
	var txfee =0;
	var msg =""; 
	var xx=createBchTranscationSig(inputprivatekeys, txids, inputamounts, indexs, outputaddresses, outputamounts, returnaddr, txfee,msg)
    console.log(xx);
	**/
</script>
	
   
</body>

</html>
